package com.example.demo.service;

import com.example.demo.dao.ArticleMapper;
import com.example.demo.dao.UserMapper;
import com.example.demo.model.Articleinfo;
import com.example.demo.model.Userinfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {

    @Autowired
    private ArticleMapper articleMapper;

    public List<Articleinfo> getListByUid(int uid) {
        return articleMapper.getListByUid(uid);
    }


    public int del(@Param("aid")Integer aid , int uid) {
        return articleMapper.del(aid,uid);
    }

    public int add (Articleinfo articleinfo) {
        return articleMapper.add(articleinfo);
    }

//    public int getArtByAid(@Param("id")Integer aid,int uid) {
//        return articleMapper.getArtByAid(aid,uid);
//    }

    public Articleinfo getArtById(@Param("aid")Integer aid) {
        return articleMapper.getArtById(aid);
    }


    public Articleinfo getArticleByUid(@Param("id")int id , @Param("uid")int uid) {
        return articleMapper.getArticleByUid(id,uid);
    }

    public int getArtCOuntByUId (@Param("uid")int uid) {
        return articleMapper.getArtCOuntByUId(uid);
    }


    public int update_sub(Articleinfo articleinfo) {
        return articleMapper.update_sub(articleinfo);
    }

    public int updateRcount(@Param("aid") Integer aid) {
        return articleMapper.updateRcount(aid);
    }
    public List<Articleinfo> getListByPage(@Param("psize") int psize,
                                           @Param("pindex") int offset) {
        return articleMapper.getListByPage(psize,offset);
    }

    public int getArtCount () {
        return articleMapper.getArtCount();
    }
}
